package org.example.controller;

import lombok.RequiredArgsConstructor;
import org.example.entity.MeetingStatisticsDTO;
import org.example.entity.TrendDataDTO;
import org.example.service.MeetingStatisticsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("api/meeting/statistics")
@RequiredArgsConstructor
public class MeetingStatisticsController {

    private final  MeetingStatisticsService statisticsService;

    /**
     * 获取会议趋势统计数据
     * 对应前端 fetchTrendData 方法的请求
     */
    @GetMapping("/trend")
    public List<TrendDataDTO> getTrendData(
            @RequestParam String statType // 统计类型：month/quarter/year
    ) {
        // 根据统计类型查询对应趋势数据
        return statisticsService.getTrendData(statType);
    }

    /**
     * 获取会议统计概览数据
     * 用于前端统计卡片展示的核心数据
     */
    @GetMapping("/overview")
    public MeetingStatisticsDTO getStatisticsOverview(
            @RequestParam String statType // 接收前端传递的统计类型
    ) {
        // 传递statType到Service层，用于按周期筛选数据
        return statisticsService.getCoreStatistics(statType);
    }
}